<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>综合练习</title>
    <style>
    body {
        padding: 50px;
    }

    td {
        width: 100px;
    }
    </style>
</head>

<body>
    <table border="1" cellspacing="0">
        <tr>
            <td>
                <button>删除本行0</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                <button>删除本行1</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                <button>删除本行2</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                <button>删除本行3</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                <button>删除本行4</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                <button>删除本行5</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                <button>删除本行6</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>
                <button>删除本行7</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
    <script>
    //效果：点击按钮，删除按钮所在行
    var button = document.getElementsByTagName("button"); //类似数组

    for (var i = 0; i < button.length; i++) { //遍历类似数组
        button[i].setAttribute("onclick", "task(this)"); //添加事件  传参
    }

    function task(that) {
        that.parentNode.parentNode.innerHTML = "";
    }
    </script>
</body>

</html>